import { Component, OnInit } from '@angular/core';
import { News } from '../../model/news';
import { NewsService } from '../../service/news.service';
import { Route } from '@angular/compiler/src/core';
import { Router, ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-managelist',
  templateUrl: './managelist.component.html',
  styleUrls: ['./managelist.component.css']
})
export class ManagelistComponent implements OnInit {
    nl:Array<News>;
  constructor(
    private newsservice:NewsService,
    private router:Router
    ,private routeinfo:ActivatedRoute

  ){}

  ngOnInit() {
       this.loadnewslist();
  }

    
  private loadnewslist(){
    this.nl=new Array();

    this.newsservice.getNewsList()
     .then((data:any)=>{
        this.nl=data;
     })
     
}
    addNews(){
      this.router.navigate(['editnews','add']);

    }
    
   editNews(id:string){
     this.router.navigate(['editnews',id]);

   }
      
}
